<?php 
include('../../Connections/KRAPPERCON.php');
$found = false;

$oper = $_POST['oper'];

if ($oper == 'upd'){
	$fecha = getVal('fecha');
	$items = getVal('items');
	
	$sql = "call sp_updTipoCambio('".$fecha."','".$items."')";
	echo $sql;
	$res = $mysqli->query($sql);
	if ($res){
		if($row = $res->fetch_assoc()){
			if ($row['newnro']>0) {
				echo "<script>showOk('Se han guardados los datos de conversión para el día ".$fecha."');</script>";
			}
			else {
				echo "<script>showError('No se han guardado los datos');</script>";
			}
			
		}
		
	}
}
else if ($oper == 'get'){
	$fecha = $_POST['fecha'];
	$sql = "call sp_getResumenTC('".$fecha."')";
	
	$res = $mysqli->query($sql);
	if ($res){
		while($row = $res->fetch_assoc()){
		if ($row['MoneyID']=='PEN') continue;
		?>
         <tr money='<?php echo $row['MoneyID'];?>'>
        <td class="tcOri"><?php echo $row['MoneyID']." - ".$row['MoneyTxt'];?></td>
        <td class="tcDes"><?php echo 'PEN - Soles'; ?></td>
        <td class="tcVal1"><input type="text" onChange="mr3(this);"  value="<?php echo $row['MoneyVal']; ?>" style="width:100%" class="qt clsReq" /></td>
        <td class="tcVal2"><input type="text" onChange="mr3(this);" value="<?php echo $row['MoneyVal2']; ?>" style="width:100%" class="qt clsReq" /></td>
      </tr>
        <?php 
		}
		$res->close();
		
		$mysqli->check_result();
		
	}
}
?>